

<div class="layui-form" lay-filter="layuiadmin-form-role" style="padding: 20px 30px 0 0;">
    <!-- 角色名称 -->
    <div class="layui-form-item">
        <label class="layui-form-label">角色名称</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="cname" value="{{ d.params.roleName || '' }}" lay-verify="required"
                       placeholder="请输入角色名称" autocomplete="off" class="layui-input">
                <input type="hidden" name="cid" value="{{ d.params.roleId || '' }}"
                       autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>

    <!-- 角色状态 -->
    <div class="layui-form-item" lay-filter="cflag">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="radio" name="cflag" value="0" title="启用"
                       {{ d.params.roleFlag === '启用' || d.params.roleFlag === '0' ? 'checked' : '' }}>
                <input type="radio" name="cflag" value="1" title="禁用"
                       {{ d.params.roleFlag === '禁用' || d.params.roleFlag === '1' ? 'checked' : '' }}>
            </script>
        </div>
    </div>

    <!-- 提交按钮 -->
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="LAY-modify" value="确认" class="layui-btn">
        </div>
    </div>
</div>

<script>
layui.use(['admin', 'form'], function(){
  var $ = layui.$
  ,form = layui.form;
  
});
layui.use([ 'form', 'layer' ], function() {
	$ = layui.$;
	var form = layui.form, layer = layui.layer;	
	
	$.ajax({
		url : '/getDeptsServlet',
		dataType : 'json', //服务器返回json格式数据
		type : 'post', //HTTP请求类型
		timeout : 10000, //超时时间设置为10秒；
		success : function(data) {			
			$.each(data.data, function(index, value) {
				$('#pdnames').append(
						new Option(value.roleName, value.roleId));// 下拉菜单里添加元素
			});			

			/// 根据id，绑定选择的值
			/* //var value='${mds.rolePid}'; */			
			$('#pdnames').val($('#pidh').val());
			form.render("select"); 
		}
	});	
});
</script>